from gradio_client import Client
import pygame
from pygame.mixer import Sound
log = []
ttsPath = []
client = Client("http://127.0.0.1:7860/")
result_0 = client.predict(
	'G_taffy2.pth',# ckpt_name
    '聚类模型.pt',# cluster_name
    '配置文件.json',# config_name
    False,# enhance = False,
    '扩散模型.pt',# diff_model_name
    '扩散模型配置文件.yaml',# diff_config_name
    False,# only_diffusion
    False,# use_spk_mix
    'Auto',# using_device
    "dpm-solver++",# method
    10,# speedup
    0,# cl_num
    'nsf_hifigan_finetuned',# vocoder_name
    api_name="/modelAnalysis",
)
def load_log(information):
    log.append(information)
def load_ttsPath(Path):
    ttsPath.append(Path)
def own_tts(talk="hello"):
    change = client.predict(
        talk,"女","Auto",0,0,"wav","acetaffy",0,False,0,-50,0.4,0.5,0,1,0.75,"rmvpe",0,0.05,400,
        False, False, 0,
        api_name="/vc_fn2",
    )
    load_log(change)
    load_ttsPath(change[1])
def ttsTalk(path):
    # 加载音频文件
    sound = Sound(path)
    # 播放音频
    sound.play()
    # 等待音频播放完毕
    while pygame.mixer.get_busy():
        pygame.time.Clock().tick(10)
def run():
    while True:
        talk = input("说点啥")
        own_tts(talk)
        ttsTalk(ttsPath[-1])





#acetaffy